package net.techwatch.jsni.client;

import com.google.gwt.dom.client.Element;
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.ui.Widget;

public class Raphael extends Widget {

	private RaphaelJS overlay;
	
	public class Shape extends Widget {
		protected RaphaelJS.Shape rs;
		
		protected Shape(RaphaelJS.Shape s) {
			setElement(s.node());
			rs = s;
		}
		
		public Shape rotate(double degree, boolean isAbsolute) {
			rs.rotate(degree, isAbsolute);
			return this;
		}
		
		public Shape translate(double dx, double dy) {
			rs.translate(dx, dy);
			return this;
		}
		
	}
	
	public class Circle extends Shape {
		public Circle(double x, double y, double r) {
			super(overlay.circle(x, y, r));
		}
	}
	
	public class Rectangle extends Shape {
		public Rectangle(double x, double y, double w, double h) {
			super(overlay.rect(x, y, w, h));
		}
	}
	
	public Raphael(int width, int height) {
		Element raphaelDiv = DOM.createDiv();
		setElement(raphaelDiv);
		overlay = RaphaelJS.create(raphaelDiv, width, height);
	}
}
